package com.proton.carepatchtemp.utils.eventbus;


import com.proton.carepatchtemp.constant.Extras;
import com.proton.carepatchtemp.utils.ResUtils;

import org.greenrobot.eventbus.EventBus;

import java.util.ArrayList;
import java.util.List;


public class MainEvent extends BaseEvent {
    public String key = "";
    // --Commented out by Inspection START (2016/3/15 11:19):
//    public MainEvent(int deviceId, Object obj, long uid) {
//        super(deviceId, obj);
//        this.key = String.valueOf(uid);
//    }
// --Commented out by Inspection STOP (2016/3/15 11:19)
    public List list = new ArrayList();

    public MainEvent(int id, String ret, String msg, Object obj) {
        super(id, ret, msg, obj);
    }

    public MainEvent(String key, int id, String ret, String msg, Object obj) {
        super(id, ret, msg, obj);
        this.key = key;
    }

    public MainEvent(int id, Object obj) {
        super(id, obj);
    }

    public MainEvent(int id) {
        super(id);
    }

    public MainEvent(String key, int id) {
        super(id);
        this.key = key;
    }

    public MainEvent(String key, int id, Object obj) {
        super(id, obj);
        this.key = key;
    }

    public MainEvent(String key, int id, String ret, String msg) {
        super(id, ret, msg);
        this.key = key;
    }

    public MainEvent(int id, String ret, String msg) {
        super(id, ret, msg);
    }

    public MainEvent(int id, String ret, int msgid) {
        super(id, ret, ResUtils.getString(msgid));
    }

    public MainEvent() {
        super();
    }

    public MainEvent(int id, List list) {
        super(id);
        this.list = list;
    }

    public MainEvent(int id, String ret, List list) {
        super(id);
        this.ret = ret;
        this.list = list;
    }

    public MainEvent(String key, int id, List list) {
        super(id);
        this.key = key;
        this.list = list;
    }

    public MainEvent(int id, String ret, String msg, List list) {
        super(id);
        this.ret = ret;
        this.msg = msg;
        this.list = list;
    }

// --Commented out by Inspection START (2016/3/15 11:19):
//    public void setKey(String key) {
//        this.key = key;
//    }
// --Commented out by Inspection STOP (2016/3/15 11:19)

// --Commented out by Inspection START (2016/3/15 11:19):
//    public void setUid(long uid) {
//        this.key = String.valueOf(uid);
//    }
// --Commented out by Inspection STOP (2016/3/15 11:19)

    public boolean isSuccess() {
        return Extras.RET_S.equalsIgnoreCase(ret);
    }

    public boolean isNotFail() {
        return !Extras.RET_F.equalsIgnoreCase(ret);
    }

    public boolean isInterval() {
        return Extras.RET_INTERVAL.equalsIgnoreCase(ret);
    }

    public boolean isFail() {
        return Extras.RET_F.equalsIgnoreCase(ret);
    }

    public String getKey() {
        return key;
    }

    public List getList() {
        return list;
    }

// --Commented out by Inspection START (2016/3/15 11:19):
//    public void setList(List list) {
//        this.list = list;
//    }
// --Commented out by Inspection STOP (2016/3/15 11:19)

    public boolean post() {
        EventBus.getDefault().post(MainEvent.this);
        return true;
    }


    public boolean isEnd() {
        return Extras.RET_END.equalsIgnoreCase(ret);
    }

    public MainEvent id(int id) {
        this.id = id;
        return this;
    }

    public MainEvent key(String key) {
        this.key = key;
        return this;
    }

    public MainEvent ret(String ret) {
        this.ret = ret;
        return this;
    }

    public MainEvent msg(int resid) {
        this.msg = ResUtils.getString(resid);
        return this;
    }

    public MainEvent msg(String msg) {
        this.msg = msg;
        return this;
    }

    public MainEvent Obj(Object obj) {
        this.obj = obj;
        return this;
    }
}
